package cn.lystudio.rohmtimeopwide_background_v11.mapper;

import cn.lystudio.rohmtimeopwide_background_v11.entity.vo.RecordTimeLineVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface RecordTimeLineMapper {
    @Select("select unionres.*,uz.userFullName\n" +
            "FROM\n" +
            "\t(SELECT \n" +
            "\t\tbr.recordID,\n" +
            "\t\tbr.userCode,\n" +
            "\t\tbr.machineNo,\n" +
            "\t\tCONCAT(br.recordType,'开始') recordType,\n" +
            "\t\tbr.recordName,\n" +
            "\t\tbr.recordResult,\n" +
            "\t\tbr.recordPart,\n" +
            "\t\tbr.abnormalHandler,\n" +
            "\t\tbr.recordTimeBeginDT recordTimeDT,\n" +
            "\t\tbr.recordSelectedColNo,\n" +
            "\t\tbr.recordLotInfo,\n" +
            "\t\tbr.recordAQRInfo,\n" +
            "\t\tbr.recordRemark,\n" +
            "\t\tbr.recordVerify\n" +
            "\tFROM t_record br \n" +
            "\tWHERE 1=1 \n" +
            "\t\tAND br.machineNo=#{machineNo}\n" +
            "\t\tAND br.recordTimeBeginDT >= #{beginDate}\n" +
            "\t\tAND br.recordTimeBeginDT <= #{endDate}\n" +
            "\tUNION ALL \n" +
            "\tSELECT \n" +
            "\t\tbr.recordID,\n" +
            "\t\tbr.userCodeEnd userCode,\n" +
            "\t\tbr.machineNo,\n" +
            //"\t\tbr.recordType,\n" +
            "\t\tCONCAT(br.recordType,'结束') recordType,\n" +
            "\t\tbr.recordName,\n" +
            "\t\tbr.recordResult,\n" +
            "\t\tbr.recordPart,\n" +
            "\t\tbr.abnormalHandler,\n" +
            "\t\tbr.recordTimeEndDT recordTimeDT,\n" +
            "\t\tbr.recordSelectedColNo,\n" +
            "\t\tbr.recordLotInfo,\n" +
            "\t\tbr.recordAQRInfo,\n" +
            "\t\tbr.recordRemark,\n" +
            "\t\tbr.recordVerify\n" +
            "\tFROM t_record br \n" +
            "\tWHERE 1=1 \n" +
            "\t\tAND br.machineNo=#{machineNo}\n" +
            "\t\tAND br.recordTimeEndDT >= #{beginDate}\n" +
            "\t\tAND br.recordTimeEndDT <= #{endDate}\n" +
            "\t) unionres\n" +
            "\tLEFT JOIN t_users uz ON uz.userCode=unionres.userCode" +
            "\tWHERE 1=1 \n" +
            "\tAND unionres.recordTimeDT>= #{beginDate}\n" +
            "\tAND unionres.recordTimeDT<= #{endDate}\n" +
            "ORDER BY unionres.recordTimeDT DESC")
    List<RecordTimeLineVO> getRecordTimeLine(@Param("machineNo")String machineNo, @Param("beginDate")String beginDate, @Param("endDate")String endDate);


}
